package bpm.dao.impl.fs;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import bpm.domain.fs.Container;

public class ContainerMergeBatchPreparedStatementSetter implements
		BatchPreparedStatementSetter {
	private List<Container> containers;
	public ContainerMergeBatchPreparedStatementSetter (List<Container> containers) {
		this.containers = containers;
	}

	public int getBatchSize() {
		return containers.size();
	}

	public void setValues(PreparedStatement pstmt, int i) throws SQLException {
		pstmt.setString(1, containers.get(i).getContainer());
		pstmt.setLong(2, containers.get(i).getCapacity());
		pstmt.setLong(3, containers.get(i).getFree());
		pstmt.setString(4, containers.get(i).getEnableString());
		pstmt.setDate(5, new Date(containers.get(i).getCreateTime().getTime()));
		pstmt.setDate(6, new Date(containers.get(i).getLastUpdateTime().getTime()));
		pstmt.setString(7, containers.get(i).getDescription());
		pstmt.setInt(8, containers.get(i).getId());
	}

}
